package com.woniu.darryringmall.front.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.darryringmall.front.entity.Collect;
import com.woniu.darryringmall.front.entity.Comment;
import com.woniu.darryringmall.front.entity.CommentVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 评论表Mapper接口
 */
public interface CommentMapper extends BaseMapper<Comment> {
    @Insert("insert into mall_comment(userId,context,time,type,goodsId) values(#{userId},#{context},#{time},#{type},#{goodsId})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    void add(Comment comment);

    @Select("select g.id gid,o.id orderId,o.orderNo,o.orderTime,g.name,g.image,g.goodsNo,o.money,o.status from mall_order o,mall_goods g,mall_orderItems os where o.status=6 and  o.id=os.orderId and os.goodsId=g.id  and o.userId=#{userId} ")
    List<CommentVo> getNoCmByUserId(int userId);

    @Select("select c.id,c.context,o.id orderId,g.id gid,o.orderNo,o.orderTime,g.name,g.image,g.goodsNo,o.money,o.status from mall_order o,mall_goods g,mall_comment c ,mall_orderItems os where o.status=7 and c.orderId=o.id and os.orderId=o.id and c.goodsId=g.id and c.userId=#{userId} ")
    List<CommentVo> getCmByUserId(int userId);
}
